<!DOCTYPE html><html><head>
      <title>3MySQL&#x6570;&#x636E;&#x5E93;</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      
      <link rel="stylesheet" href="file:///C:\Users\Administrator\.vscode\extensions\shd101wyy.markdown-preview-enhanced-0.4.3\node_modules\@shd101wyy\mume\dependencies\katex\katex.min.css">
      
      

      
      
      
      
      
      

      <style>
      /**
 * prism.js Github theme based on GitHub's theme.
 * @author Sam Clarke
 */
code[class*="language-"],
pre[class*="language-"] {
  color: #333;
  background: none;
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.4;

  -moz-tab-size: 8;
  -o-tab-size: 8;
  tab-size: 8;

  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
  padding: .8em;
  overflow: auto;
  /* border: 1px solid #ddd; */
  border-radius: 3px;
  /* background: #fff; */
  background: #f5f5f5;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
  padding: .1em;
  border-radius: .3em;
  white-space: normal;
  background: #f5f5f5;
}

.token.comment,
.token.blockquote {
  color: #969896;
}

.token.cdata {
  color: #183691;
}

.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
  color: #333;
}

.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
  color: #a71d5d;
}

.token.string,
.token.url,
.token.regex,
.token.attr-value {
  color: #183691;
}

.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
  color: #0086b3;
}

.token.tag,
.token.selector,
.token.prolog {
  color: #63a35c;
}

.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
  color: #795da3;
}

.token.entity {
  cursor: help;
}

.token.title,
.token.title .token.punctuation {
  font-weight: bold;
  color: #1d3e81;
}

.token.list {
  color: #ed6a43;
}

.token.inserted {
  background-color: #eaffea;
  color: #55a532;
}

.token.deleted {
  background-color: #ffecec;
  color: #bd2c00;
}

.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}


/* JSON */
.language-json .token.property {
  color: #183691;
}

.language-markup .token.tag .token.punctuation {
  color: #333;
}

/* CSS */
code.language-css,
.language-css .token.function {
  color: #0086b3;
}

/* YAML */
.language-yaml .token.atrule {
  color: #63a35c;
}

code.language-yaml {
  color: #183691;
}

/* Ruby */
.language-ruby .token.function {
  color: #333;
}

/* Markdown */
.language-markdown .token.url {
  color: #795da3;
}

/* Makefile */
.language-makefile .token.symbol {
  color: #795da3;
}

.language-makefile .token.variable {
  color: #183691;
}

.language-makefile .token.builtin {
  color: #0086b3;
}

/* Bash */
.language-bash .token.keyword {
  color: #0086b3;
}

/* highlight */
pre[data-line] {
  position: relative;
  padding: 1em 0 1em 3em;
}
pre[data-line] .line-highlight-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  background-color: transparent;
  display: block;
  width: 100%;
}

pre[data-line] .line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  padding: inherit 0;
  margin-top: 1em;
  background: hsla(24, 20%, 50%,.08);
  background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
  pointer-events: none;
  line-height: inherit;
  white-space: pre;
}

pre[data-line] .line-highlight:before, 
pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-start);
  position: absolute;
  top: .4em;
  left: .6em;
  min-width: 1em;
  padding: 0 .5em;
  background-color: hsla(24, 20%, 50%,.4);
  color: hsl(24, 20%, 95%);
  font: bold 65%/1.5 sans-serif;
  text-align: center;
  vertical-align: .3em;
  border-radius: 999px;
  text-shadow: none;
  box-shadow: 0 1px white;
}

pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-end);
  top: auto;
  bottom: .4em;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{padding:0 1.6em;margin-top:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc li{margin-bottom:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{list-style-type:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% -  300px);padding:2em calc(50% - 457px -  150px);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */

      </style>
    </head>
    <body for="html-export">
      <div class="mume markdown-preview  ">
      <h1 class="mume-header" id="-%E6%95%B0%E6%8D%AE%E5%BA%93%E5%9F%BA%E6%9C%AC%E5%B8%B8%E8%AF%86">:-: &#x6570;&#x636E;&#x5E93;&#x57FA;&#x672C;&#x5E38;&#x8BC6;</h1>

<h3 class="mume-header" id="1-%E4%BB%80%E4%B9%88%E6%98%AFmysql">1&#x3001;&#x4EC0;&#x4E48;&#x662F;MySQL</h3>

<ul>
<li><code>DBMS</code>: ( Database Management System)&#x6570;&#x636E;&#x5E93;&#x7BA1;&#x7406;&#x7CFB;&#x7EDF;</li>
<li><code>RDBMS</code>: (Relational Database Management System)
<ul>
<li>&#x4E2D;&#x6587;: &#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;&#x7BA1;&#x7406;&#x7CFB;&#x7EDF;</li>
<li>&#x5173;&#x7CFB;: &#x53EF;&#x6682;&#x65F6;&#x7B80;&#x5355;&#x7684;&#x7406;&#x89E3;&#x4E3A;&#x4E00;&#x5F20;&#x4E8C;&#x7EF4;&#x8868;&#x683C;</li>
<li><code>MySQL</code>: &#x6700;&#x6D41;&#x884C;&#x7684;<strong>&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;&#x7BA1;&#x7406;&#x7CFB;&#x7EDF;</strong></li>
</ul>
</li>
</ul>
<hr>
<h3 class="mume-header" id="2-%E4%B8%BA%E4%BB%80%E4%B9%88-mysql-%E5%A6%82%E6%AD%A4%E6%B5%81%E8%A1%8C">2&#x3001;&#x4E3A;&#x4EC0;&#x4E48; MySQL &#x5982;&#x6B64;&#x6D41;&#x884C;</h3>

<ul>
<li>&#x514D;&#x8D39;&#x5F00;&#x6E90;, &#x4F7F;&#x7528;&#x7B80;&#x5355;: &#x4F7F;&#x7528;&#x6210;&#x672C;&#x4F4E;</li>
<li>&#x6027;&#x80FD;&#x4F18;&#x5F02;, &#x793E;&#x533A;&#x6D3B;&#x8DC3;: &#x9047;&#x5230;&#x95EE;&#x9898;&#x53EF;&#x5FEB;&#x901F;&#x627E;&#x5230;&#x89E3;&#x51B3;&#x65B9;&#x6848;</li>
<li>&#x5DE8;&#x5934;&#x7EF4;&#x62A4;, &#x5B89;&#x5168;&#x653E;&#x5FC3;: Oracle&#x516C;&#x53F8;&#x4EA7;&#x54C1;</li>
<li>&#x4E0E; PHP / Apache &#x662F;&#x4E00;&#x5BF9;&#x57FA;&#x53CB;, &#x4E0D;&#x79BB;&#x4E0D;&#x5F03;, &#x751F;&#x6B7B;&#x76F8;&#x4F9D;</li>
</ul>
<hr>
<h3 class="mume-header" id="3-rdbms-%E5%9F%BA%E6%9C%AC%E6%9C%AF%E8%AF%AD">3&#x3001;RDBMS &#x57FA;&#x672C;&#x672F;&#x8BED;</h3>

<ul>
<li>&#x6570;&#x636E;&#x5E93;: &#x4E00;&#x7EC4;&#x76F8;&#x5173;&#x8054;&#x7684;&#x6570;&#x636E;&#x8868;&#x7684;&#x96C6;&#x5408;, &#x7C7B;&#x4F3C;&#x4E8E;&#x76EE;&#x5F55;</li>
<li>&#x6570;&#x636E;&#x8868;: &#x4E00;&#x5F20;&#x7528;&#x6765;&#x5B58;&#x50A8;&#x6570;&#x636E;&#x7684;&#x4E8C;&#x7EF4;&#x8868;&#x683C;, &#x7C7B;&#x4F3C;&#x4E8E;&#x6587;&#x4EF6;</li>
</ul>
<blockquote>
<p>[info] &#x6570;&#x636E;&#x5E93;&#x4E0E;&#x6570;&#x636E;&#x8868;&#x4E4B;&#x95F4;&#x7684;&#x5173;&#x7CFB;, &#x7C7B;&#x4F3C;&#x4E8E;&#x76EE;&#x5F55;&#x4E0E;&#x6587;&#x4EF6;&#x4E4B;&#x95F4;&#x7684;&#x5173;&#x7CFB;</p>
</blockquote>
<p><img src="http://kanyun.8car.net/php/db1.png" alt></p>
<ul>
<li>&#x884C;: &#x4E5F;&#x53EB;&#x8BB0;&#x5F55;, &#x662F;&#x4E00;&#x7EC4;&#x76F8;&#x5173;&#x6570;&#x636E;&#x7684;&#x96C6;&#x5408;, &#x4F8B;&#x5982;&#x67D0;&#x4E2A;&#x7528;&#x6237;&#x7684;&#x76F8;&#x5173;&#x4FE1;&#x606F;</li>
<li>&#x5217;: &#x4E5F;&#x53EB;&#x5B57;&#x6BB5;, &#x67D0;&#x4E2A;&#x5177;&#x4F53;&#x6570;&#x636E;,&#x4F8B;&#x5982;&#x7528;&#x6237;&#x59D3;&#x540D;: admin</li>
<li>&#x4E3B;&#x952E;: &#x552F;&#x4E00;&#x8BC6;&#x522B;&#x67D0;&#x4E00;&#x884C;&#x8BB0;&#x5F55;&#x7684;&#x5B57;&#x6BB5;&#x540D;&#x79F0;, &#x4E00;&#x5F20;&#x8868;&#x53EA;&#x80FD;&#x6709;&#x4E00;&#x4E2A;&#x4E3B;&#x952E;,&#x4F8B;&#x5982;id</li>
<li>&#x5916;&#x952E;: &#x5173;&#x4E8E;&#x5173;&#x8054;&#x4E8C;&#x5F20;&#x6570;&#x636E;&#x8868;&#x7684;,&#x5373;&#x5F53;&#x524D;&#x8868;&#x7684;&#x5916;&#x952E;,&#x5E94;&#x8BE5;&#x662F;&#x53E6;&#x4E00;&#x5F20;&#x8868;&#x7684;&#x4E3B;&#x952E;</li>
<li>&#x7D22;&#x5F15;: &#x7C7B;&#x4F3C;&#x5B57;&#x5178;&#x7684;&#x7D22;&#x5F15;, &#x5728;&#x7279;&#x5B9A;&#x5B57;&#x6BB5;&#x4E0A;&#x521B;&#x5EFA;,&#x7528;&#x6765;&#x5FEB;&#x901F;&#x67E5;&#x8BE2;&#x6570;&#x636E;</li>
</ul>
<p><img src="http://kanyun.8car.net/php/db2.png" alt></p>
<hr>
<h3 class="mume-header" id="4-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7">4&#x3001;&#x6570;&#x636E;&#x5E93;&#x7BA1;&#x7406;&#x5DE5;&#x5177;</h3>

<ul>
<li>MySQL&#x5DE5;&#x5177;&#x5F88;&#x591A;&#xFF0C;&#x4E3B;&#x8981;&#x6709;&#x5BA2;&#x6237;&#x7AEF;&#x548C;&#x7F51;&#x9875;&#x7248;
<ul>
<li>phpMyAdmin &#x7F51;&#x9875;&#x7248;</li>
<li>Navicat for MySql &#x5BA2;&#x6237;&#x7AEF;</li>
</ul>
</li>
</ul>
<hr>
<h3 class="mume-header" id="5-mysql%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B">5&#x3001;MySQL&#x6570;&#x636E;&#x7C7B;&#x578B;</h3>

<p><img src="http://kanyun.8car.net/php/db3.png" alt></p>
<hr>
<h3 class="mume-header" id="6-%E5%B8%B8%E7%94%A8%E6%95%B0%E6%8D%AE%E5%BA%93%E6%93%8D%E4%BD%9C%E8%AF%AD%E5%8F%A5">6&#x3001;&#x5E38;&#x7528;&#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;&#x8BED;&#x53E5;</h3>

<ul>
<li>&#x6700;&#x5E38;&#x7528;&#x7684;&#x5C31;&#x662F;: <code>CURD</code> &#x589E;&#x5220;&#x6539;&#x67E5;</li>
<li><code>SQL</code>&#x8BED;&#x53E5;&#x7F16;&#x5199;&#x89C4;&#x8303;
<ul>
<li>&#x5173;&#x952E;&#x5B57;&#x5168;&#x90E8;&#x5927;&#x5199;: <code>SELECT / INSERT / DELETE / UPDATE ...</code></li>
<li>&#x8868;&#x540D;&#x4E0E;&#x5B57;&#x6BB5;&#x540D;&#x4F7F;&#x7528;&#x53CD;&#x5F15;&#x53F7;&#x5B9A;&#x754C;&#x7B26;: &#x8868;&#x540D;<code>user</code>, &#x5B57;&#x6BB5;&#x540D;<code>email</code></li>
<li>&#x5177;&#x4F53;&#x503C;,&#x6709;&#x7C7B;&#x578B;&#x4E0E;&#x957F;&#x5EA6;&#x7B49;&#x5C5E;&#x6027;</li>
</ul>
</li>
</ul>
<p><img src="http://kanyun.8car.net/php/db4.png" alt></p>
<hr>
<h3 class="mume-header" id="7-%E5%88%9B%E5%BB%BA%E6%95%B0%E6%8D%AE%E8%A1%A8">7&#x3001;&#x521B;&#x5EFA;&#x6570;&#x636E;&#x8868;</h3>

<pre data-role="codeBlock" data-info class="language-"><code># &#x521B;&#x5EFA;&#x5206;&#x7C7B;&#x8868;
CREATE TABLE `category` (
	`cate_id` int(3) unsigned NOT NULL AUTO_INCREMENT COMMENT &apos;&#x4E3B;&#x952E;&apos;,
	`name` varchar(30) NOT NULL COMMENT &apos;&#x680F;&#x76EE;&#x540D;&#x79F0;&apos;,
	`alias` varchar(30) NOT NULL COMMENT &apos;&#x680F;&#x76EE;&#x522B;&#x540D;&apos;,
	PRIMARY KEY (`cate_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

# &#x521B;&#x5EFA;&#x5F71;&#x89C6;&#x8868;
CREATE TABLE `movies` (
	`mov_id` int(2) unsigned NOT NULL AUTO_INCREMENT COMMENT &apos;&#x4E3B;&#x952E;&apos;,
	`name` varchar(100) NOT NULL COMMENT &apos;&#x5F71;&#x89C6;&#x5267;&#x540D;&apos;,
	`image` varchar(100) NOT NULL,
	`detail` text NOT NULL,
	`cate_id` int(3) unsigned NOT NULL COMMENT &apos;&#x6240;&#x5C5E;&#x680F;&#x76EE;&apos;,
	PRIMARY KEY (`mov_id`),
	KEY `cate_id` (`cate_id`),
	CONSTRAINT `movies_ibfk_1` FOREIGN KEY (`cate_id`) REFERENCES `category` (`cate_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

# &#x521B;&#x5EFA;&#x7CFB;&#x7EDF;&#x8868;
CREATE TABLE `system` (
	`sys_id` int(1) unsigned NOT NULL AUTO_INCREMENT COMMENT &apos;&#x4E3B;&#x952E;&apos;,
	`title` varchar(50) NOT NULL COMMENT &apos;&#x9875;&#x9762;&#x6807;&#x9898;&apos;,
	`desc` varchar(200) NOT NULL COMMENT &apos;&#x9875;&#x9762;&#x63CF;&#x8FF0;&apos;,
	`key` varchar(50) NOT NULL COMMENT &apos;&#x5173;&#x952E;&#x5B57;&apos;,
	`copy` varchar(50) NOT NULL COMMENT &apos;&#x7248;&#x6743;&apos;,
	PRIMARY KEY (`sys_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</code></pre><hr>
<h3 class="mume-header" id="7-%E6%96%B0%E5%A2%9E%E8%AE%B0%E5%BD%95">7&#x3001;&#x65B0;&#x589E;&#x8BB0;&#x5F55;</h3>

<blockquote>
<p>[info] &#x65B0;&#x589E;&#x64CD;&#x4F5C;&#x6709;&#x4E8C;&#x5957;&#x8BED;&#x6CD5;&#x89C4;&#x8303;</p>
</blockquote>
<ul>
<li>SQL&#x89C4;&#x8303;: <code>INSERT INTO</code>&#x6570;&#x636E;&#x8868;<code>(</code>&#x5B57;&#x6BB5;1<code>,</code>&#x5B57;&#x6BB5;2<code>...) VALUES (&apos;&#x503C;1&apos;,&apos;&#x503C;2&apos;...)</code>
<ul>
<li>&#x4F18;&#x70B9;: &#x901A;&#x7528;&#x89C4;&#x8303;, &#x79FB;&#x690D;&#x6027;&#x597D;, &#x53EF;&#x540C;&#x65F6;&#x63D2;&#x5165;&#x591A;&#x6761;&#x8BB0;&#x5F55;</li>
<li>&#x7F3A;&#x70B9;: &#x5B57;&#x6BB5;&#x4E0E;&#x503C;&#x7684;&#x987A;&#x5E8F;&#x5FC5;&#x987B;&#x4E00;&#x4E00;&#x5BF9;&#x5E94;, &#x5BB9;&#x6613;&#x51FA;&#x73B0;&#x62FC;&#x5199;&#x9519;&#x8BEF;</li>
</ul>
</li>
<li>MySQL&#x6269;&#x5C55;: <code>INSERT INTO</code>&#x6570;&#x636E;&#x8868;<code>SET</code>&#x5B57;&#x6BB5;1<code>=&apos;&#x503C;1&apos;,</code>&#x5B57;&#x6BB5;2<code>=&apos;&#x503C;2&apos;...</code>
<ul>
<li>&#x4F18;&#x70B9;: &#x8BED;&#x6CD5;&#x7B80;&#x6D01;&#x4F18;&#x96C5;, &#x6267;&#x884C;&#x6548;&#x7387;&#x662F;&#x4F20;&#x7EDF;&#x8BED;&#x6CD5;&#x7684;3&#x500D;&#x4EE5;&#x4E0A;</li>
<li>&#x7F3A;&#x70B9;: &#x53EA;&#x9002;&#x7528;&#x4E8E;<code>MySQL</code>&#x6570;&#x636E;&#x5E93;, &#x79FB;&#x690D;&#x6027;&#x5DEE;,&#x5E76;&#x4E14;&#x4E0D;&#x652F;&#x6301;&#x540C;&#x65F6;&#x63D2;&#x5165;&#x591A;&#x6761;&#x8BB0;&#x5F55;</li>
</ul>
</li>
</ul>
<blockquote>
<p>[danger] Tips: &#x8BED;&#x53E5;&#x4E2D;&#x7684; <code>INTO</code> &#x53EF;&#x4EE5;&#x7701;&#x7565;, &#x4E3B;&#x952E;&#x53EF;&#x5FFD;&#x7565;&#x8D4B;&#x503C;,&#x5982;&#x679C;&#x8D4B;&#x503C;&#x5FC5;&#x987B;&#x662F;&#x4E3A;<code>NULL</code></p>
</blockquote>
<pre data-role="codeBlock" data-info class="language-"><code># &#x6DFB;&#x52A0;&#x5206;&#x7C7B;&#x8868;
INSERT INTO `category` (`cate_id`, `name`, `alias`) VALUES (1, &apos;gc&apos;, &apos;&#x56FD;&#x4EA7;&#x597D;&#x5267;&apos;);
INSERT INTO `category` (`name`, `alias`) VALUES (&apos;om&apos;,&apos;&#x6B27;&#x7F8E;&#x731B;&#x7247;&apos;);
INSERT INTO `category` SET `name`=&apos;rh&apos;, `alias`=&apos;&#x6B27;&#x7F8E;&#x731B;&#x7247;&apos;;

# &#x6DFB;&#x52A0;&#x5F71;&#x89C6;&#x8868;
INSERT INTO `movies` (`mov_id`, `name`, `image`, `detail`, `cate_id`) VALUES
(1,	&apos;&#x501A;&#x5929;&#x5C60;&#x9F99;&#x8BB0;&apos;,	&apos;1.jpg&apos;,	&apos;&#x5143;&#x671D;&#x672B;&#x5E74;&#xFF0C;&#x7FA4;&#x96C4;&#x7EB7;&#x8D77;&#xFF0C;&#x6B66;&#x6797;&#x52A8;&#x8361;&#x3002;&#x6C5F;&#x6E56;&#x4F20;&#x95FB;&#xFF0C;&#x5F97;&#x5230;&#x5C60;&#x9F99;&#x5200;&#x501A;&#x5929;&#x5251;&#x8005;&#xFF0C;&#x53EF;&#x4EE5;&#x6210;&#x4E3A;&#x6B66;&#x6797;&#x81F3;&#x5C0A;&#xFF0C;&#x53F7;&#x4EE4;&#x5929;&#x4E0B;&#xFF0C;&#x83AB;&#x6562;&#x4E0D;&#x4ECE;&#x3002;&#x4E00;&#x65F6;&#x95F4;&#x98CE;&#x4E91;&#x56DB;&#x8D77;&#xFF0C;&#x5F15;&#x53D1;&#x4E86;&#x6B66;&#x6797;&#x4E2D;&#x5BF9;&#x5C60;&#x9F99;&#x5200;&#x501A;&#x5929;&#x5251;&#x7684;&#x4E89;&#x593A;&#xFF0C;&#x51E0;&#x6BB5;&#x59FB;&#x7F18;&#x548C;&#x5B7D;&#x7F18;&#x4E5F;&#x7531;&#x6B64;&#x4EA7;&#x751F;&#x3002;&#x6B66;&#x5F53;&#x6D3E;&#x5F20;&#x7FE0;&#x5C71;&#x4E0E;&#x5929;&#x9E70;&#x6559;&#x6BB7;&#x7D20;&#x7D20;&#x56E0;&#x5C60;&#x9F99;&#x5200;&#x76F8;&#x9047;&#x76F8;&#x604B;&#xFF0C;&#x6700;&#x540E;&#x4EA6;&#x56E0;&#x5C60;&#x9F99;&#x5200;&#x88AB;&#x6B63;&#x6D3E;&#x4EBA;&#x58EB;&#x6240;&#x903C;&#x8FEB;&#xFF0C;&#x53CC;&#x53CC;&#x81EA;&#x5C3D;&#x3002;&#x4ED6;&#x4EEC;&#x7684;&#x513F;&#x5B50;&#x5F20;&#x65E0;&#x5FCC;&#x957F;&#x5927;&#x6210;&#x4EBA;&#x540E;&#xFF0C;&#x673A;&#x7F18;&#x5DE7;&#x5408;&#x4E0B;&#x7EC3;&#x6210;&#x4E86;&#x7EDD;&#x4E16;&#x6B66;&#x529F;&#x201C;&#x4E5D;&#x9633;&#x795E;&#x529F;&#x201D;&#x548C;&#x201C;&#x4E7E;&#x5764;&#x5927;&#x632A;&#x79FB;&#x201D;&#xFF0C;&#x6210;&#x4E3A;&#x4E86;&#x660E;&#x6559;&#x6559;&#x4E3B;&#x3002; &#x5F20;&#x65E0;&#x5FCC;&#x4E0E;&#x5143;&#x671D;&#x90E1;&#x4E3B;&#x8D75;&#x654F;&#x3001;&#x5CE8;&#x5D4B;&#x6D3E;&#x5468;&#x82B7;&#x82E5;&#x3001;&#x8868;&#x59B9;&#x6BB7;&#x79BB;&#x548C;&#x5A62;&#x5973;&#x5C0F;&#x662D;&#x90FD;&#x6709;&#x7740;&#x5343;&#x4E1D;&#x4E07;&#x7F15;&#x7684;&#x7231;&#x610F;&#x3002;&#x7136;&#x800C;&#xFF0C;&#x770B;&#x4F3C;&#x67D4;&#x5F31;&#x7684;&#x5468;&#x82B7;&#x82E5;&#xFF0C;&#x5374;&#x662F;&#x4E2A;&#x5341;&#x8DB3;&#x7684;&#x201C;&#x8179;&#x9ED1;&#x5973;&#x201D;&#xFF0C;&#x5979;&#x4E3A;&#x4E86;&#x83B7;&#x53D6;&#x501A;&#x5929;&#x5251;&#x5C60;&#x9F99;&#x5200;&#x7684;&#x79D8;&#x5BC6;&#xFF0C;&#x4E0D;&#x60DC;&#x6740;&#x5BB3;&#x6BB7;&#x79BB;&#xFF0C;&#x9677;&#x5BB3;&#x8D75;&#x654F;&#x3002;&#x5F20;&#x65E0;&#x5FCC;&#x867D;&#x770B;&#x6E05;&#x4E86;&#x5468;&#x82B7;&#x82E5;&#x771F;&#x5B9E;&#x9762;&#x76EE;&#xFF0C;&#x4F46;&#x4ECD;&#x5272;&#x820D;&#x4E0D;&#x4E0B;&#x5979;&#x3002;&#x5176;&#x540E;&#xFF0C;&#x5F20;&#x65E0;&#x5FCC;&#x5316;&#x89E3;&#x4E86;&#x6B66;&#x6797;&#x79CD;&#x79CD;&#x6069;&#x6028;&#xFF0C;&#x8F9E;&#x53BB;&#x6559;&#x4E3B;&#x4E4B;&#x4F4D;&#xFF0C;&#x4E0E;&#x8D75;&#x654F;&#x5BC4;&#x8FF9;&#x8499;&#x53E4;&#x3002;&apos;,	1),
(2,	&apos;&#x90FD;&#x633A;&#x597D;&apos;,	&apos;2.jpg&apos;,	&apos; &#x82CF;&#x6BCD;&#x7684;&#x7684;&#x7A81;&#x7136;&#x79BB;&#x4E16;&#x6253;&#x7834;&#x4E86;&#x8FD9;&#x4E2A;&#x5BB6;&#x5EAD;&#x5916;&#x8868;&#x7684;&#x5E73;&#x9759;&#xFF0C;&#x610F;&#x60F3;&#x4E0D;&#x5230;&#x7684;&#x9690;&#x60A3;&#x5C42;&#x5C42;&#x663E;&#x9732;&#xFF0C;&#x5BF9;&#x6BEB;&#x65E0;&#x4E3B;&#x89C1;&#x5374;&#x53C8;&#x81EA;&#x79C1;&#x3001;&#x5C0F;&#x6C14;&#x7684;&#x82CF;&#x7236;&#x7684;&#x5B89;&#x7F6E;&#x548C;&#x540E;&#x7EED;&#x751F;&#x6D3B;&#x95EE;&#x9898;&#xFF0C;&#x5F15;&#x53D1;&#x4E86;&#x8FDC;&#x5728;&#x56FD;&#x5916;&#x7684;&#x5927;&#x54E5;&#x4E0E;&#x672C;&#x57CE;&#x7684;&#x4E8C;&#x54E5;&#x3001;&#x5C0F;&#x59B9;&#x4E09;&#x5BB6;&#x89C4;&#x5F8B;&#x751F;&#x6D3B;&#x7684;&#x4E0D;&#x518D;&#x3002;&#x4E00;&#x76F4;&#x88AB;&#x82CF;&#x6BCD;&#x538B;&#x5236;&#x7684;&#x82CF;&#x7236;&#x7FFB;&#x8EAB;&#x7A81;&#x53D8;&#xFF0C;&#x4ED6;&#x7684;&#x51B7;&#x6F20;&#x81EA;&#x79C1;&#x5C06;&#x82CF;&#x5BB6;&#x7684;&#x65E7;&#x4F24;&#x75D5;&#x6495;&#x6210;&#x4E86;&#x4E00;&#x9053;&#x9053;&#x8840;&#x6DCB;&#x6DCB;&#x7684;&#x4EB2;&#x60C5;&#x9E3F;&#x6C9F;&#xFF1B;&#x5927;&#x54E5;&#x82CF;&#x660E;&#x54F2;&#x4E00;&#x5FC3;&#x611A;&#x5B5D;&#xFF0C;&#x5374;&#x4E0D;&#x65AD;&#x4F24;&#x5BB3;&#x4ED6;&#x5728;&#x7F8E;&#x56FD;&#x7684;&#x5C0F;&#x5BB6;&#x5EAD;&#x7684;&#x798F;&#x7949;&#xFF0C;&#x5A5A;&#x59FB;&#x548C;&#x4E8B;&#x4E1A;&#x51E0;&#x5EA6;&#x9762;&#x4E34;&#x5371;&#x673A;&#xFF1B;&#x4E8C;&#x54E5;&#x82CF;&#x660E;&#x6210;&#x662F;&#x4E60;&#x60EF;&#x5543;&#x8001;&#x7684;&#x5BA0;&#x513F;&#xFF0C;&#x7F3A;&#x4E4F;&#x9A91;&#x58EB;&#x7CBE;&#x795E;&#xFF0C;&#x6BCD;&#x4EB2;&#x7684;&#x6B7B;&#x8BA9;&#x4ED6;&#x7A81;&#x7136;&#x9762;&#x4E34;&#x5FC3;&#x7406;&#x65AD;&#x5976;&#xFF0C;&#x832B;&#x7136;&#x4ED3;&#x7687;&#xFF0C;&#x5BFC;&#x81F4;&#x4E8B;&#x4E1A;&#x5D29;&#x6E83;&#xFF0C;&#x7834;&#x4EA7;&#x79BB;&#x5A5A;&#xFF1B;&#x800C;&#x672C;&#x5267;&#x7684;&#x4E3B;&#x89D2;&#x5C0F;&#x59B9;&#x82CF;&#x660E;&#x7389;&#xFF0C;&#x6709;&#x7740;&#x53EF;&#x7591;&#x8EAB;&#x4E16;&#xFF0C;&#x4ECE;&#x5C0F;&#x4E0D;&#x53D7;&#x7236;&#x6BCD;&#x5F85;&#x89C1;&#xFF0C;&#x6028;&#x6068;&#x6BCD;&#x4EB2;&#x7684;&#x4E0D;&#x516C;&#xFF0C;&#x4E0A;&#x5927;&#x5B66;&#x6CA1;&#x7528;&#x8FC7;&#x5BB6;&#x91CC;&#x4E00;&#x5206;&#x94B1;&#xFF0C;&#x6BD5;&#x4E1A;&#x540E;&#x5BB6;&#x91CC;&#x5374;&#x6CA1;&#x6709;&#x5979;&#x7684;&#x4E09;&#x5C3A;&#x5E8A;&#xFF0C;&#x9760;&#x7740;&#x81EA;&#x5F3A;&#x3001;&#x62FC;&#x640F;&#xFF0C;&#x6210;&#x4E3A;&#x4E00;&#x5BB6;&#x5927;&#x578B;&#x96C6;&#x56E2;&#x957F;&#x6C5F;&#x4EE5;&#x5357;&#x5730;&#x533A;&#x7684;&#x9500;&#x552E;&#x4E3B;&#x7BA1;&#x3002;&#x5979;&#x4E00;&#x76F4;&#x8868;&#x6001;&#x8981;&#x548C;&#x82CF;&#x5BB6;&#x4E00;&#x5200;&#x4E24;&#x65AD;&#xFF0C;&#x62FC;&#x547D;&#x5730;&#x9003;&#x79BB;&#xFF0C;&#x5374;&#x59CB;&#x7EC8;&#x9003;&#x4E0D;&#x6389;&#x4EB2;&#x60C5;&#x7684;&#x7F81;&#x7ECA;&#xFF0C;&#x5728;&#x82CF;&#x5BB6;&#x7684;&#x4E00;&#x6B21;&#x6B21;&#x5371;&#x673A;&#x4E2D;&#x51FA;&#x624B;&#x76F8;&#x52A9;&#x3002;&#x82CF;&#x660E;&#x7389;&#x51B7;&#x773C;&#x770B;&#x7740;&#x7236;&#x6BCD;&#x4E0D;&#x5E78;&#x7684;&#x5A5A;&#x59FB;&#x751F;&#x6D3B;&#xFF0C;&#x4E00;&#x6B21;&#x53C8;&#x4E00;&#x6B21;&#x4E3A;&#x81EA;&#x5DF1;&#x548C;&#x6BCD;&#x4EB2;&#x7684;&#x76F8;&#x4F3C;&#x60CA;&#x6050;&#x4E0D;&#x5DF2;&#xFF0C;&#x6CA1;&#x6709;&#x52C7;&#x6C14;&#x53BB;&#x9762;&#x5BF9;&#x5A5A;&#x59FB;&#xFF0C;&#x5728;&#x201C;&#x6696;&#x7537;&#x201D;&#x77F3;&#x5929;&#x51AC;&#x7684;&#x8FFD;&#x6C42;&#x4E0B;&#xFF0C;&#x5C55;&#x5F00;&#x4E86;&#x4E00;&#x6BB5;&#x770B;&#x4F3C;&#x4E0D;&#x822C;&#x914D;&#xFF0C;&#x5374;&#x6070;&#x6070;&#x4E92;&#x8865;&#x7684;&#x7231;&#x60C5;&#xFF0C;&#x6700;&#x7EC8;&#x653E;&#x5F00;&#x8EAB;&#x4E16;&#x4E4B;&#x75DB;&#x3002;&apos;,	1),
(3,	&apos;&#x5982;&#x679C;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#x7231;&apos;,	&apos;3.jpg&apos;,	&apos;&#x4E00;&#x5BF9;&#x5DF2;&#x5A5A;&#x7537;&#x5973;&#x7A81;&#x7136;&#x5F87;&#x60C5;&#x81EA;&#x6740;&#xFF0C;&#x4EE5;&#x4E3A;&#x53EF;&#x4EE5;&#x7ED3;&#x675F;&#x8FD9;&#x4E00;&#x5207;&#xFF0C;&#x5374;&#x4E0D;&#x6599;&#x60B2;&#x5267;&#x624D;&#x521A;&#x521A;&#x5F00;&#x59CB;&#x2014;&#x2014;&#x4ED6;&#x4EEC;&#x7684;&#x7231;&#x4EBA;&#xFF0C;&#x803F;&#x58A8;&#x6C60;&#x548C;&#x767D;&#x8003;&#x513F;&#xFF0C;&#x540C;&#x65F6;&#x5728;&#x846C;&#x793C;&#x4E0A;&#x9082;&#x9005;&#x3002;&#x9762;&#x5BF9;&#x540C;&#x6837;&#x7684;&#x80CC;&#x53DB;&#x4ED6;&#x4EEC;&#x540C;&#x65F6;&#x9009;&#x62E9;&#x62A5;&#x590D;&#x4F46;&#x53C8;&#x540C;&#x65F6;&#x7231;&#x4E0A;&#x5F7C;&#x6B64;&#xFF0C;&#x6CE8;&#x5B9A;&#x9971;&#x53D7;&#x6253;&#x51FB;&#x548C;&#x6298;&#x78E8;&#x3002;&#x7136;&#x800C;&#x4ED6;&#x4EEC;&#x60F3;&#x771F;&#x5FC3;&#x62E5;&#x6709;&#x5F7C;&#x6B64;&#x65F6;&#xFF0C;&#x8001;&#x5929;&#x5DF2;&#x4E0D;&#x7ED9;&#x4ED6;&#x4EEC;&#x673A;&#x4F1A;&#xFF0C;&#x803F;&#x58A8;&#x6C60;&#x8EAB;&#x60A3;&#x4E0D;&#x6CBB;&#x4E4B;&#x75C7;&#x6CE8;&#x5B9A;&#x8981;&#x79BB;&#x53BB;&#xFF0C;&#x800C;&#x8FD9;&#x65F6;&#x5019;&#x767D;&#x8003;&#x513F;&#x4EA1;&#x592B;&#x7684;&#x54E5;&#x54E5;&#x7941;&#x6811;&#x793C;&#x51FA;&#x73B0;&#x4E86;&#xFF0C;&#x7EA0;&#x7ED3;&#x5728;&#x4E24;&#x4E2A;&#x7537;&#x4EBA;&#x4E4B;&#x95F4;&#xFF0C;&#x6700;&#x7EC8;&#x4E00;&#x4E2A;&#x8D70;&#x5411;&#x5A5A;&#x793C;&#xFF0C;&#x4E00;&#x4E2A;&#x8D70;&#x5411;&#x846C;&#x793C;&#x3002;&apos;,	1),
(4,	&apos;&#x590D;&#x4EC7;&#x8005;&#x8054;&#x76DF;4&apos;,	&apos;4.jpg&apos;,	&apos;&#x300A;&#x590D;&#x4EC7;&#x8005;&#x8054;&#x76DF;4&#xFF1A;&#x7EC8;&#x5C40;&#x4E4B;&#x6218;&#x300B;&#x5C06;&#x662F;&#x6F2B;&#x5A01;&#x5B87;&#x5B99;&#x201C;&#x65E0;&#x9650;&#x4F20;&#x5947;&#x201D;&#xFF08;The Infinity Saga)&#x7684;&#x7EC8;&#x7ED3;&#x7BC7;&#xFF0C;&#x662F;&#x6F2B;&#x5A01;&#x7535;&#x5F71;&#x5B87;&#x5B99;&#x5341;&#x5E74;&#x7684;&#x4E00;&#x4E2A;&#x91CD;&#x8981;&#x8282;&#x70B9;&#xFF0C;&#x7ED3;&#x675F;&#x90E8;&#x5206;&#x82F1;&#x96C4;&#x7535;&#x5F71;&#x7684;&#x6545;&#x4E8B;&#xFF0C;&#x4F46;&#x4E5F;&#x5C06;&#x5C55;&#x5F00;&#x65B0;&#x7684;&#x5267;&#x60C5;&#xFF0C;&#x5448;&#x73B0;&#x65B0;&#x7684;&#x66F4;&#x4E3A;&#x5E7F;&#x9614;&#x5B8F;&#x5927;&#x7684;&#x5B87;&#x5B99;&#x89C2;&#xFF0C;&#x672A;&#x6765;&#x4E5F;&#x5C06;&#x51FA;&#x73B0;&#x65B0;&#x7684;&#x8D85;&#x7EA7;&#x82F1;&#x96C4;&#xFF0C;&#x7EE7;&#x7EED;&#x6F2B;&#x5A01;&#x8D85;&#x7EA7;&#x82F1;&#x96C4;&#x6FC0;&#x52A8;&#x4EBA;&#x5FC3;&#x7684;&#x6545;&#x4E8B;&#x3002;&#x6F2B;&#x5A01;&#x5F71;&#x4E1A;&#x8363;&#x8A89;&#x51FA;&#x54C1;&#x300A;&#x590D;&#x4EC7;&#x8005;&#x8054;&#x76DF;4&#xFF1A;&#x7EC8;&#x5C40;&#x4E4B;&#x6218;&#x300B;&#xFF0C;&#x6545;&#x4E8B;&#x53D1;&#x751F;&#x5728;&#x706D;&#x9738;&#x6D88;&#x706D;&#x5B87;&#x5B99;&#x4E00;&#x534A;&#x7684;&#x751F;&#x7075;&#x5E76;&#x91CD;&#x521B;&#x590D;&#x4EC7;&#x8005;&#x8054;&#x76DF;&#x4E4B;&#x540E;&#xFF0C;&#x5269;&#x4F59;&#x7684;&#x82F1;&#x96C4;&#x88AB;&#x8FEB;&#x80CC;&#x6C34;&#x4E00;&#x6218;&#xFF0C;&#x4E3A;22&#x90E8;&#x6F2B;&#x5A01;&#x7535;&#x5F71;&#x5199;&#x4E0B;&#x4F20;&#x5947;&#x7EC8;&#x7AE0;&#x3002;&apos;,	2),
(5,	&apos;&#x6CE2;&#x897F;&#x7C73;&#x4E9A;&#x72C2;&#x60F3;&#x66F2;&apos;,	&apos;5.jpg&apos;,	&apos;&#x5F17;&#x96F7;&#x8FEA;&#xB7;&#x9ED8;&#x4E18;&#x91CC;&#x6210;&#x540D;&#x524D;&#x5728;&#x673A;&#x573A;&#x505A;&#x884C;&#x674E;&#x642C;&#x8FD0;&#x5DE5;&#x3002;&#x6709;&#x4E00;&#x5929;&#xFF0C;&#x9ED8;&#x4E18;&#x91CC;&#x6BDB;&#x9042;&#x81EA;&#x8350;&#x52A0;&#x5165;&#x6770;&#xB7;&#x6CF0;&#x52D2;&#x4E0E;&#x5E03;&#x83B1;&#x6069;&#xB7;&#x6885;&#x7684;&#x4E50;&#x56E2;&#xFF0C;&#x6070;&#x5DE7;&#x5F53;&#x5929;&#x539F;&#x672C;&#x7684;&#x4E3B;&#x5531;&#x8F9E;&#x804C;&#xFF0C;&#x9ED8;&#x4E18;&#x91CC;&#x7528;&#x81EA;&#x5DF1;&#x6A2A;&#x8DE8;&#x56DB;&#x4E2A;&#x516B;&#x5EA6;&#x7684;&#x8D85;&#x5E7F;&#x97F3;&#x57DF;&#x8BF4;&#x670D;&#x4E24;&#x4EBA;&#xFF0C;&#x4ECE;&#x6B64;&#x5F00;&#x542F;&#x7687;&#x540E;&#x4E50;&#x56E2;&#x7684;&#x6447;&#x6EDA;&#x4F20;&#x5947;!&apos;,	2),
(6,	&apos;&#x963F;&#x4E3D;&#x5854;:&#x6218;&#x6597;&#x5929;&#x4F7F;&apos;,	&apos;6.jpg&apos;,	&apos;&#x5728;26&#x4E16;&#x7EAA;&#x7684;&#x4E16;&#x754C;&#x4E2D;&#xFF0C;&#x4E0A;&#x7B49;&#x4EBA;&#x4F4F;&#x5728;&#x6D6E;&#x5728;&#x534A;&#x7A7A;&#x4E2D;&#x4E00;&#x4E2A;&#x540D;&#x53EB;&#x6492;&#x51B7;&#x7684;&#x7A7A;&#x95F4;&#x7AD9;&#x91CC;&#xFF0C;&#x800C;&#x5E73;&#x6C11;&#x767E;&#x59D3;&#x5219;&#x5728;&#x5E9F;&#x571F;&#x4E00;&#x822C;&#x7684;&#x5730;&#x8868;&#x94A2;&#x94C1;&#x57CE;&#x4E2D;&#x751F;&#x6D3B;&#x3002;&#x94A2;&#x94C1;&#x57CE;&#x91CC;&#x4EBA;&#x7C7B;&#x4E0E;&#x673A;&#x68B0;&#x6539;&#x9020;&#x4EBA;&#x5171;&#x5B58;&#xFF0C;&#x5F31;&#x8089;&#x5F3A;&#x98DF;&#x662F;&#x94A2;&#x94C1;&#x57CE;&#x4E2D;&#x552F;&#x4E00;&#x7684;&#x751F;&#x5B58;&#x6CD5;&#x5219;&#x3002;&#x94A2;&#x94C1;&#x57CE;&#x4E2D;&#x8457;&#x540D;&#x7684;&#x6539;&#x9020;&#x4EBA;&#x533B;&#x751F;&#x4F9D;&#x5FB7;&#xFF08;&#x514B;&#x91CC;&#x65AF;&#x6258;&#x5F17;&#xB7;&#x74E6;&#x5C14;&#x5179;&#x9970;&#xFF09;&#x5728;&#x4E00;&#x4E2A;&#x5783;&#x573E;&#x573A;&#x53D1;&#x73B0;&#x4E86;&#x4E00;&#x4E2A;&#x534A;&#x673A;&#x68B0;&#x5C11;&#x5973;&#x7684;&#x6B8B;&#x8EAF;&#xFF0C;&#x4ED6;&#x5C06;&#x5176;&#x6539;&#x9020;&#x6210;&#x4E3A;&#x6709;&#x7740;&#x673A;&#x68B0;&#x8EAB;&#x4F53;&#x7684;&#x5C11;&#x5973;&#xFF0C;&#x4F9D;&#x5FB7;&#x4E3A;&#x91CD;&#x751F;&#x7684;&#x5C11;&#x5973;&#x53D6;&#x540D;&#x963F;&#x4E3D;&#x5854;&#xFF08;&#x7F57;&#x838E;&#xB7;&#x8428;&#x62C9;&#x624E;&#x5C14;&#x9970;&#xFF09;&#x3002;&#x963F;&#x4E3D;&#x5854;&#x5931;&#x53BB;&#x4E86;&#x8FC7;&#x5F80;&#x7684;&#x8BB0;&#x5FC6;&#xFF0C;&#x72B9;&#x5982;&#x65B0;&#x751F;&#x513F;&#x4E00;&#x822C;&#x5BF9;&#x4E16;&#x754C;&#x5145;&#x6EE1;&#x597D;&#x5947;&#x3002;&#x5979;&#x9047;&#x5230;&#x4E86;&#x8857;&#x5934;&#x5C11;&#x5E74;&#x96E8;&#x679C;&#xFF08;&#x57FA;&#x6069;&#xB7;&#x7EA6;&#x7FF0;&#x900A;&#x9970;&#xFF09;&#xFF0C;&#x4E24;&#x4EBA;&#x4E92;&#x751F;&#x597D;&#x611F;&#x3002;&#x5929;&#x771F;&#x70C2;&#x6F2B;&#x7684;&#x963F;&#x4E3D;&#x5854;&#x5076;&#x7136;&#x95F4;&#x53D1;&#x73B0;&#x81EA;&#x5DF1;&#x6709;&#x7740;&#x60CA;&#x4EBA;&#x7684;&#x6218;&#x6597;&#x529B;&#xFF0C;&#x800C;&#x5979;&#x5728;&#x9762;&#x5BF9;&#x53AE;&#x6740;&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x6162;&#x6162;&#x6062;&#x590D;&#x4E86;&#x8BB0;&#x5FC6;&#xFF0C;&#x4E5F;&#x5F00;&#x59CB;&#x60F3;&#x8D77;&#x81EA;&#x5DF1;&#x7684;&#x4F7F;&#x547D;&apos;,	2),
(7,	&apos;&#x60C5;&#x4E66;&apos;,	&apos;7.jpg&apos;,	&apos;&#x65E5;&#x672C;&#x795E;&#x6237;&#x67D0;&#x4E2A;&#x98D8;&#x96EA;&#x7684;&#x51AC;&#x65E5;&#xFF0C;&#x6E21;&#x8FB9;&#x535A;&#x5B50;&#xFF08;&#x4E2D;&#x5C71;&#x7F8E;&#x7A57;&#xFF09;&#x5728;&#x524D;&#x672A;&#x5A5A;&#x592B;&#x85E4;&#x4E95;&#x6811;&#x7684;&#x4E09;&#x5468;&#x5E74;&#x796D;&#x65E5;&#x4E0A;&#x53C8;&#x4E00;&#x6B21;&#x60B2;&#x75DB;&#x5230;&#x4E0D;&#x80FD;&#x81EA;&#x5DF2;&#x3002;&#x6B63;&#x56E0;&#x4E3A;&#x65E0;&#x6CD5;&#x6291;&#x5236;&#x4F4F;&#x5BF9;&#x5DF2;&#x901D;&#x604B;&#x4EBA;&#x7684;&#x601D;&#x5FF5;&#xFF0C;&#x6E21;&#x8FB9;&#x535A;&#x5B50;&#x5728;&#x5176;&#x4E2D;&#x5B66;&#x540C;&#x5B66;&#x5F55;&#x91CC;&#x53D1;&#x73B0;&#x201C;&#x85E4;&#x4E95;&#x6811;&#x201D; &#x5728;&#x5C0F;&#x6A3D;&#x5E02;&#x8BFB;&#x4E66;&#x65F6;&#x7684;&#x5730;&#x5740;&#x65F6;&#xFF0C;&#x4F9D;&#x5FAA;&#x7740;&#x5BC4;&#x53D1;&#x4E86;&#x4E00;&#x5C01;&#x672C;&#x4EE5;&#x4E3A;&#x662F;&#x53D1;&#x5F80;&#x5929;&#x56FD;&#x7684;&#x60C5;&#x4E66;&#x3002;\r\n&#x3000;&#x3000;&#x4E0D;&#x60F3;&#x4E0D;&#x4E45;&#x6E21;&#x8FB9;&#x535A;&#x5B50;&#x7ADF;&#x7136;&#x6536;&#x5230;&#x7F72;&#x540D;&#x4E3A;&#x201C;&#x85E4;&#x4E95;&#x6811;&#xFF08;&#x4E2D;&#x5C71;&#x7F8E;&#x7A57;&#xFF09;&#x201D;&#x7684;&#x56DE;&#x4FE1;&#xFF0C;&#x7ECF;&#x8FC7;&#x8FDB;&#x4E00;&#x6B65;&#x4E86;&#x89E3;&#xFF0C;&#x5979;&#x77E5;&#x6653;&#x6B64;&#x85E4;&#x4E95;&#x6811;&#x662F;&#x4E00;&#x4E2A;&#x540C;&#x5979;&#x5E74;&#x7EAA;&#x76F8;&#x4EFF;&#x7684;&#x5973;&#x5B69;&#xFF0C;&#x4E14;&#x8FD8;&#x662F;&#x7537;&#x53CB;&#x85E4;&#x4E95;&#x6811;&#xFF08;&#x67CF;&#x539F;&#x5D07;&#xFF09;&#x5C11;&#x5E74;&#x65F6;&#x4EE3;&#x7684;&#x540C;&#x73ED;&#x540C;&#x5B66;&#x3002;&#x4E3A;&#x4E86;&#x591A;&#x4E86;&#x89E3;&#x4E00;&#x4E9B;&#x6614;&#x65E5;&#x604B;&#x4EBA;&#x5728;&#x4E2D;&#x5B66;&#x65F6;&#x4EE3;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x6E21;&#x8FB9;&#x535A;&#x5B50;&#x5F00;&#x59CB;&#x4E0E;&#x5973;&#x6027;&#x85E4;&#x4E95;&#x6811;&#x4E66;&#x4FE1;&#x5F80;&#x6765;&#x3002;&#x800C;&#x85E4;&#x4E95;&#x6811;&#x5728;&#x4E0D;&#x65AD;&#x7684;&#x56DE;&#x5FC6;&#x4E2D;&#xFF0C;&#x6E10;&#x6E10;&#x53D1;&#x73B0;&#x5C11;&#x5E74;&#x65F6;&#x4EE3;&#x4E0E;&#x5979;&#x540C;&#x540D;&#x540C;&#x59D3;&#x7684;&#x90A3;&#x4E2A;&#x85E4;&#x4E95;&#x6811;&#x66FE;&#x5BF9;&#x81EA;&#x5DF1;&#x85CF;&#x4E86;&#x4E00;&#x8154;&#x67D4;&#x60C5;&apos;,	3),
(8,	&apos;&#x5929;&#x7A7A;&#x4E4B;&#x57CE;&apos;,	&apos;8.jpg&apos;,	&apos;&#x97E9;&#x4E66;&#x73CD;&#x5C06;&#x4E24;&#x4E2A;&#x5973;&#x513F;&#x7684;&#x6559;&#x80B2;&#x95EE;&#x9898;&#x548C;&#x5BF9;&#x4E08;&#x592B;&#x7684;&#x8D24;&#x5185;&#x52A9;&#x5DE5;&#x4F5C;&#x90FD;&#x505A;&#x5F97;&#x4E95;&#x4E95;&#x6709;&#x6761;&#xFF0C;&#x5728;&#x5929;&#x7A7A;&#x4E4B;&#x57CE;&#x4E4B;&#x4E2D;&#x4E5F;&#x662F;&#x5907;&#x53D7;&#x77A9;&#x76EE;&#x7684;&#x5973;&#x738B;&#xFF0C;&#x4F46;&#x5176;&#x5B9E;&#x4E66;&#x73CD;&#x4E00;&#x76F4;&#x9690;&#x85CF;&#x7740;&#x4E0D;&#x4E3A;&#x4EBA;&#x6240;&#x77E5;&#x7684;&#x79D8;&#x5BC6;&#x3002;&#x674E;&#x79C0;&#x6797;&#x662F;&#x4E2A;&#x5145;&#x6EE1;&#x4E86;&#x5173;&#x6000;&#x548C;&#x60C5;&#x611F;&#x4E30;&#x6C9B;&#x7684;&#x7AE5;&#x8BDD;&#x4F5C;&#x5BB6;&#xFF0C;&#x5728;&#x4E66;&#x73CD;&#x7684;&#x5F15;&#x5BFC;&#x4E4B;&#x4E0B;&#x6210;&#x4E3A;&#x4E86;&#x5929;&#x7A7A;&#x4E4B;&#x57CE;&#x5973;&#x738B;&#x4EEC;&#x7684;&#x516C;&#x5171;&#x4E4B;&#x654C;&#xFF0C;&#x4F46;&#x591A;&#x4E8F;&#x806A;&#x660E;&#x7684;&#x513F;&#x5B50;&#x5E2E;&#x5FD9;&#xFF0C;&#x4E00;&#x5EA6;&#x6210;&#x4E3A;&#x4E86;&#x65B0;&#x4E00;&#x4EFB;&#x5973;&#x738B;&#xFF0C;&#x751A;&#x81F3;&#x5728;&#x90A3;&#x4E4B;&#x540E;&#x8FD8;&#x770B;&#x51FA;&#x4E86;&#x4E66;&#x73CD;&#x7684;&#x79D8;&#x5BC6;&#x3002;&#x8BFB;&#x5B8C;&#x535A;&#x4E4B;&#x540E;&#x56DE;&#x5F52;&#x505A;&#x5BB6;&#x5EAD;&#x4E3B;&#x5987;&#x7684;&#x5362;&#x80DC;&#x6167;&#xFF0C;&#x4ECE;&#x5C0F;&#x5BB6;&#x6559;&#x4E25;&#x82DB;&#xFF0C;&#x4E00;&#x76F4;&#x662F;&#x4E2A;&#x4E56;&#x4E56;&#x5973;&#xFF0C;&#x4F46;&#x5176;&#x5B9E;&#x9690;&#x85CF;&#x7740;&#x5185;&#x5FC3;&#x4E0D;&#x65AD;&#x8981;&#x6D8C;&#x51FA;&#x6765;&#x7684;&#x6B32;&#x671B;&#x548C;&#x70B8;&#x5F39;&#x3002;&#x70ED;&#x60C5;&#x53C8;&#x53EF;&#x7231;&#x7684;&#x8D2D;&#x7269;&#x72C2;&#x9648;&#x771F;&#x7199;&#xFF0C;&#x56E0;&#x4E3A;&#x8001;&#x7238;&#x624B;&#x4E2D;&#x5750;&#x62E5;&#x5927;&#x697C;&#xFF0C;&#x4ECE;&#x5C0F;&#x5C31;&#x662F;&#x91D1;&#x679D;&#x7389;&#x53F6;&#xFF0C;&#x5979;&#x5C06;&#x97E9;&#x4E66;&#x73CD;&#x89C6;&#x4F5C;&#x6977;&#x6A21;&#xFF0C;&#x5FD9;&#x4E8E;&#x5B66;&#x4E60;&#x5979;&#x7684;&#x4E3E;&#x624B;&#x6295;&#x8DB3;&apos;,	3),
(9,	&apos;&#x9F99;&#x732B;&apos;,	&apos;9.jpg&apos;,	&apos;&#x4E3A;&#x4E86;&#x65B9;&#x4FBF;&#x59BB;&#x5B50;&#x8349;&#x58C1;&#x9756;&#x5B50;&#x517B;&#x75C5;&#xFF0C;&#x8349;&#x58C1;&#x8FBE;&#x90CE;&#x51B3;&#x5B9A;&#x5E26;&#x7740;&#x4E24;&#x4E2A;&#x5973;&#x513F;&#x8349;&#x58C1;&#x768B;&#x6708;&#x548C;&#x8349;&#x58C1;&#x7C73;&#x642C;&#x5230;&#x8349;&#x58C1;&#x9756;&#x5B50;&#x6240;&#x5728;&#x7597;&#x517B;&#x9662;&#x9644;&#x8FD1;&#x7684;&#x4E61;&#x4E0B;&#xFF0C;&#x7236;&#x5973;&#x4E09;&#x4EBA;&#x5165;&#x4F4F;&#x4E86;&#x4E00;&#x95F4;&#x5E74;&#x4E45;&#x5931;&#x4FEE;&#x7684;&#x8001;&#x623F;&#x5B50;&#x3002;&#x5C0F;&#x59D0;&#x59B9;&#x4FE9;&#x5F88;&#x5FEB;&#x53D1;&#x73B0;&#x770B;&#x4F3C;&#x5E73;&#x51E1;&#x65E0;&#x5947;&#x7684;&#x4E61;&#x4E0B;&#x6709;&#x5F88;&#x591A;&#x795E;&#x5947;&#x7684;&#x4E8B;&#x7269;&#xFF0C;&#x65E0;&#x4EBA;&#x5C45;&#x4F4F;&#x7684;&#x623F;&#x5C4B;&#x91CC;&#x80FD;&#x805A;&#x80FD;&#x6563;&#x8FD8;&#x80FD;&#x98DE;&#x7684;&#x201C;&#x7164;&#x7070;&#x201D;&#x3001;&#x68EE;&#x6797;&#x91CC;&#x7684;&#x5C0F;&#x7CBE;&#x7075;&#x3001;&#x68EE;&#x6797;&#x7684;&#x4E3B;&#x4EBA;&#x9F99;&#x732B;&#x548C;&#x7B11;&#x53E3;&#x5E38;&#x5F00;&#x7684;&#x732B;&#x5DF4;&#x58EB;&#x3002;&apos;,	3);
</code></pre><hr>
<h3 class="mume-header" id="8-%E6%9B%B4%E6%96%B0%E8%AE%B0%E5%BD%95">8&#x3001;&#x66F4;&#x65B0;&#x8BB0;&#x5F55;</h3>

<ul>
<li><code>UPDATE</code>&#x6570;&#x636E;&#x8868;<code>SET</code>&#x5B57;&#x6BB5;1<code>=&apos;&#x503C;1&apos;,</code>&#x5B57;&#x6BB5;2<code>=&apos;&#x503C;2&apos;... WHERE &#x66F4;&#x65B0;&#x6761;&#x4EF6;</code></li>
<li>&#x4E0D;&#x8981;&#x65E0;&#x6761;&#x4EF6;&#x66F4;&#x65B0;</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>UPDATE category SET `alias`=&apos;&#x65E5;&#x97E9;&#x65B0;&#x7247;&apos; WHERE cate_id = 3
</code></pre><hr>
<h3 class="mume-header" id="9-%E5%88%A0%E9%99%A4%E8%AE%B0%E5%BD%95">9&#x3001;&#x5220;&#x9664;&#x8BB0;&#x5F55;</h3>

<ul>
<li><code>DELETE FROM</code>&#x6570;&#x636E;&#x8868;<code>WHERE &#x5220;&#x9664;&#x6761;&#x4EF6;</code></li>
<li>&#x4E0E;&#x66F4;&#x65B0;&#x4E00;&#x6837;, &#x4E0D;&#x80FD;&#x7701;&#x7565;&#x5220;&#x9664;&#x6761;&#x4EF6;</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>DELETE FROM movies WHERE mov_id = 9
</code></pre><blockquote>
<p>[info] <code>INSERT / UPDATE / DELETE</code>: &#x90FD;&#x662F;&#x5199;&#x64CD;&#x4F5C;, &#x4F1A;&#x5F71;&#x54CD;&#x5230;&#x5F53;&#x524D;&#x6570;&#x636E;&#x8868;&#x4E2D;&#x7684;&#x8BB0;&#x5F55;&#x5185;&#x5BB9;,&#x8FD4;&#x56DE;&#x53D7;&#x5F71;&#x54CD;&#x7684;&#x8BB0;&#x5F55;&#x6570;&#x91CF;</p>
</blockquote>
<hr>
<h3 class="mume-header" id="10-%E6%9F%A5%E8%AF%A2%E6%93%8D%E4%BD%9C">10&#x3001;&#x67E5;&#x8BE2;&#x64CD;&#x4F5C;</h3>

<ul>
<li><code>SELECT</code>&#x5B57;&#x6BB5;&#x5217;&#x8868;<code>FROM</code>&#x6570;&#x636E;&#x8868;&#x540D;<code>WHERE &#x67E5;&#x8BE2;&#x6761;&#x4EF6;</code></li>
<li>&#x7ED3;&#x679C;&#x96C6;&#x63A7;&#x5236;: <code>ORDER BY</code>&#x6392;&#x5E8F;, <code>GROUP BY</code>&#x5206;&#x7EC4;, <code>LIMIT</code>&#x9650;&#x5236;&#x6570;&#x91CF;...</li>
<li>&#x4E3E;&#x4F8B;: <code>SELECT * FROM</code>user<code>WHERE</code>id<code>&gt; 10 LIMIT 5</code></li>
<li>&#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#x662F;&#x6700;&#x7075;&#x6D3B;,&#x4E5F;&#x662F;&#x6700;&#x5E38;&#x7528;&#x7684;&#x529F;&#x80FD;, &#x65E5;&#x5E38;80%&#x4EE5;&#x4E0A;&#x64CD;&#x4F5C;&#x4E0E;&#x67E5;&#x8BE2;&#x76F8;&#x5173;</li>
<li>&#x67E5;&#x8BE2;&#x4E0D;&#x4F1A;&#x5F71;&#x54CD;&#x5230;&#x8868;&#x4E2D;&#x6570;&#x636E;, &#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x96C6;</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>DELETE FROM movies WHERE mov_id = 9
</code></pre><hr>
<h1 class="mume-header" id="-pdo%E6%93%8D%E4%BD%9C%E6%95%B0%E6%8D%AE%E5%BA%93">:-: PDO&#x64CD;&#x4F5C;&#x6570;&#x636E;&#x5E93;</h1>

<h3 class="mume-header" id="1-%E4%BB%80%E4%B9%88%E6%98%AF-pdo">1. &#x4EC0;&#x4E48;&#x662F; PDO</h3>

<ul>
<li>PDO: (Php Data Object) php&#x6570;&#x636E;&#x5BF9;&#x8C61;</li>
<li>PDO &#x7EDF;&#x4E00;&#x4E86;PHP&#x8BBF;&#x95EE;&#x5404;&#x79CD;&#x7C7B;&#x578B;&#x6570;&#x636E;&#x5E93;&#x7684;&#x8BBF;&#x95EE;&#x65B9;&#x5F0F;</li>
<li>&#x4E00;&#x53E5;&#x8BDD;, &#x4E0D;&#x7BA1;&#x4EC0;&#x4E48;&#x7C7B;&#x578B;&#x6570;&#x636E;&#x5E93;, PDO&#x4E00;&#x62DB;&#x641E;&#x5B9A;</li>
</ul>
<p><img src="http://kanyun.8car.net/php/db5.png" alt></p>
<hr>
<h4 class="mume-header" id="2-pdo-%E8%BF%9E%E6%8E%A5">2. PDO &#x8FDE;&#x63A5;</h4>

<ul>
<li><code>PDO</code>: pdo&#x5BF9;&#x8C61;(&#x8FDE;&#x63A5;&#x5BF9;&#x8C61;)</li>
</ul>
<p><img src="http://kanyun.8car.net/php/db7.png" alt></p>
<pre data-role="codeBlock" data-info class="language-"><code># connect.php&#x6587;&#x4EF6;
// &#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;&#x53C2;&#x6570;
$db =  [
    &apos;type&apos; =&gt; &apos;mysql&apos;,
    &apos;host&apos; =&gt; &apos;localhost&apos;,
    &apos;dbname&apos; =&gt; &apos;php&apos;,
    &apos;username&apos; =&gt; &apos;root&apos;,
    &apos;password&apos; =&gt; &apos;root&apos;,
];

// &#x914D;&#x7F6E;&#x6570;&#x636E;&#x6E90;DSN&#x4FE1;&#x606F;
$dsn = &quot;{$db[&apos;type&apos;]}:host={$db[&apos;host&apos;]};dbname={$db[&apos;dbname&apos;]}&quot;;

// &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;
try {
	$pdo = new PDO($dsn, $db[&apos;username&apos;], $db[&apos;password&apos;]);
} catch (PDOException $e) {
	die(&apos;Connection Failed: &apos; . $e-&gt;getMessage());
}
</code></pre><hr>
<h3 class="mume-header" id="3-pdo-%E9%A2%84%E5%A4%84%E7%90%86">3. PDO &#x9884;&#x5904;&#x7406;</h3>

<ul>
<li><code>PDOStatement</code>: &#x9884;&#x5904;&#x7406;&#x5BF9;&#x8C61;(SQL&#x8BED;&#x53E5;&#x5BF9;&#x8C61;)</li>
<li><code>prepare()</code>: &#x9884;&#x5904;&#x7406;&#x65B9;&#x6CD5;, &#x7528;&#x6765;&#x751F;&#x6210;&#x9884;&#x5904;&#x7406;&#x5BF9;&#x8C61;<code>PDOStatement</code></li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>// 1. &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;
require __DIR__ . &apos;/connect.php&apos;;

// 2. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;
$sql = &apos;INSERT INTO `system` SET `sys_id`= :sys_id, `title`=:title, `desc`=:desc, `key`=:key, `copy`=:copy&apos;;

// 3. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x5BF9;&#x8C61;
$stmt = $pdo-&gt;prepare($sql);
</code></pre><hr>
<h3 class="mume-header" id="4-pdo-%E7%BB%91%E5%AE%9A%E5%8F%82%E6%95%B0">4. PDO &#x7ED1;&#x5B9A;&#x53C2;&#x6570;</h3>

<ul>
<li><code>bindParam()</code>: &#x5C06;&#x53C2;&#x6570;&#x7ED1;&#x5B9A;&#x5230;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;&#x4E0A;</li>
<li>&#x5E38;&#x7528;&#x7684;&#x9884;&#x5B9A;&#x4E49;&#x5E38;&#x91CF;&#xFF1A;
<ul>
<li><code>PDO::PARAM_INT</code>: &#x6574;&#x6570;&#x7C7B;&#x578B;</li>
<li><code>PDO::PARAM_STR</code>: &#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;</li>
<li><code>PDO::FETCH_ASSOC</code>: &#x83B7;&#x53D6;&#x7ED3;&#x679C;&#x96C6;&#x4E2D;&#x7684;&#x5173;&#x8054;&#x90E8;&#x5206;</li>
</ul>
</li>
</ul>
<pre data-role="codeBlock" data-info class="language-"><code>// 1. &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;
require __DIR__ . &apos;/connect.php&apos;;

// 2. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;
$sql = &apos;INSERT INTO `system` SET `sys_id`= :sys_id, `title`=:title, `desc`=:desc, `key`=:key, `copy`=:copy&apos;;

// 3. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x5BF9;&#x8C61;
$stmt = $pdo-&gt;prepare($sql);

// 4. &#x5C06;&#x53D8;&#x91CF;&#x7ED1;&#x5B9A;&#x5230;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;&#x7684;&#x547D;&#x540D;&#x5360;&#x4F4D;&#x7B26;&#x4E0A;
$sys_id = 1;
$title = &apos;&#x79C1;&#x4EBA;&#x5F71;&#x9662;&apos;;
$desc = &apos;&#x6536;&#x96C6;&#x5168;&#x7F51;&#x6700;&#x65B0;&#x6700;&#x5168;&#x7684;&#x5F71;&#x89C6;&#x8D44;&#x6E90;&apos;;
$key = &apos;&#x56FD;&#x4EA7;,&#x6B27;&#x7F8E;,&#x65E5;&#x97E9;&apos;;
$copy = &apos;&#x6B27;&#x9633;&#x514B;&apos;;
$stmt-&gt;bindParam(&apos;sys_id&apos;, $sys_id, PDO::PARAM_INT);
$stmt-&gt;bindParam(&apos;title&apos;, $title, PDO::PARAM_STR);
$stmt-&gt;bindParam(&apos;desc&apos;, $desc, PDO::PARAM_STR);
$stmt-&gt;bindParam(&apos;key&apos;, $key, PDO::PARAM_STR);
$stmt-&gt;bindParam(&apos;copy&apos;, $copy, PDO::PARAM_STR);
</code></pre><hr>
<h3 class="mume-header" id="5-pdostatement-%E7%B1%BB%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95">5. PDOStatement &#x7C7B;&#x5E38;&#x7528;&#x65B9;&#x6CD5;</h3>

<ul>
<li><code>execute()</code>: &#x6267;&#x884C;SQL&#x8BED;&#x53E5;(&#x8BFB;/&#x5199;)</li>
<li><code>rowCount()</code>: &#x8FD4;&#x56DE;&#x53D7;&#x5F71;&#x54CD;&#x7684;&#x8BB0;&#x5F55;&#x6570;&#x91CF;(&#x4E0D;&#x9002;&#x5408;SELECT)</li>
<li><code>errorInfo()</code>: &#x8FD4;&#x56DE;&#x9519;&#x8BEF;&#x4FE1;&#x606F;&#x6570;&#x7EC4;</li>
<li><code>fetch()</code>: &#x83B7;&#x53D6;&#x7ED3;&#x679C;&#x96C6;&#x4E2D;&#x7684;&#x4E0B;&#x4E00;&#x884C;</li>
<li><code>fetchAll()</code>: &#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x96C6;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x884C;</li>
<li><code>fetchColumn()</code>: &#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x96C6;&#x4E0B;&#x4E00;&#x884C;&#x7684;&#x5355;&#x72EC;&#x7684;&#x4E00;&#x5217;</li>
<li><code>bindColumn()</code>: &#x5C06;&#x7ED3;&#x679C;&#x96C6;&#x67D0;&#x5B57;&#x6BB5;&#x7ED1;&#x5B9A;&#x5230;&#x6307;&#x5B9A;&#x53D8;&#x91CF;&#x4E0A;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token shell-comment comment"># &#x65B0;&#x589E;&#x8BB0;&#x5F55;</span>
<span class="token comment">// 1. &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;</span>
<span class="token keyword">require</span> <span class="token constant">__DIR__</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;/connect.php&apos;</span><span class="token punctuation">;</span>

<span class="token comment">// 2. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;</span>
<span class="token variable">$sql</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;INSERT INTO `system` SET `sys_id`= :sys_id, `title`=:title, `desc`=:desc, `key`=:key, `copy`=:copy&apos;</span><span class="token punctuation">;</span>

<span class="token comment">// 3. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x5BF9;&#x8C61;</span>
<span class="token variable">$stmt</span> <span class="token operator">=</span> <span class="token variable">$pdo</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">prepare</span><span class="token punctuation">(</span><span class="token variable">$sql</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// 4. &#x5C06;&#x53D8;&#x91CF;&#x7ED1;&#x5B9A;&#x5230;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;&#x7684;&#x547D;&#x540D;&#x5360;&#x4F4D;&#x7B26;&#x4E0A;</span>
<span class="token variable">$sys_id</span> <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token variable">$title</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x79C1;&#x4EBA;&#x5F71;&#x9662;&apos;</span><span class="token punctuation">;</span>
<span class="token variable">$desc</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x6536;&#x96C6;&#x5168;&#x7F51;&#x6700;&#x65B0;&#x6700;&#x5168;&#x7684;&#x5F71;&#x89C6;&#x8D44;&#x6E90;&apos;</span><span class="token punctuation">;</span>
<span class="token variable">$key</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x56FD;&#x4EA7;,&#x6B27;&#x7F8E;,&#x65E5;&#x97E9;&apos;</span><span class="token punctuation">;</span>
<span class="token variable">$copy</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x6B27;&#x9633;&#x514B;&apos;</span><span class="token punctuation">;</span>
<span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">bindParam</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;sys_id&apos;</span><span class="token punctuation">,</span> <span class="token variable">$sys_id</span><span class="token punctuation">,</span> <span class="token scope">PDO<span class="token punctuation">::</span></span><span class="token constant">PARAM_INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">bindParam</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;title&apos;</span><span class="token punctuation">,</span> <span class="token variable">$title</span><span class="token punctuation">,</span> <span class="token scope">PDO<span class="token punctuation">::</span></span><span class="token constant">PARAM_STR</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">bindParam</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;desc&apos;</span><span class="token punctuation">,</span> <span class="token variable">$desc</span><span class="token punctuation">,</span> <span class="token scope">PDO<span class="token punctuation">::</span></span><span class="token constant">PARAM_STR</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">bindParam</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;key&apos;</span><span class="token punctuation">,</span> <span class="token variable">$key</span><span class="token punctuation">,</span> <span class="token scope">PDO<span class="token punctuation">::</span></span><span class="token constant">PARAM_STR</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">bindParam</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;copy&apos;</span><span class="token punctuation">,</span> <span class="token variable">$copy</span><span class="token punctuation">,</span> <span class="token scope">PDO<span class="token punctuation">::</span></span><span class="token constant">PARAM_STR</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// 5. &#x6267;&#x884C;SQL&#x64CD;&#x4F5C;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">execute</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">rowCount</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&gt;</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x6210;&#x529F;&#x6DFB;&#x52A0;&apos;</span> <span class="token punctuation">.</span> <span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">rowCount</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&#x6761;&#x8BB0;&#x5F55;, &#x8BE5;&#x8BB0;&#x5F55;&#x7684;&#x4E3B;&#x952E;id&#x662F;: &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$pdo</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">lastInsertId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
    <span class="token keyword">die</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&lt;pre&gt;&apos;</span> <span class="token punctuation">.</span> <span class="token function">print_r</span><span class="token punctuation">(</span><span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">errorInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token comment">// 6. &#x9500;&#x6BC1;pdo, &#x5173;&#x95ED;&#x8FDE;&#x63A5;</span>
<span class="token variable">$pdo</span> <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>   <span class="token comment">// unset($pdo) &#x7B49;&#x4EF7;</span>
</pre><pre data-role="codeBlock" data-info class="language-"><code># &#x66F4;&#x65B0;&#x8BB0;&#x5F55;
// 1. &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;
require __DIR__ . &apos;/connect.php&apos;;

// 2. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;
$sql = &apos;UPDATE  `category` SET `name` = :name, `alias` = :alias WHERE `cate_id`=:cate_id&apos;;

// 3. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x5BF9;&#x8C61;
$stmt = $pdo-&gt;prepare($sql);

// 4. &#x5C06;&#x53D8;&#x91CF;&#x7ED1;&#x5B9A;&#x5230;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;&#x7684;&#x547D;&#x540D;&#x5360;&#x4F4D;&#x7B26;&#x4E0A;
$name = &apos;xjj&apos;;
$alias = &apos;&#x5C0F;&#x59D0;&#x59D0;&apos;;
$cate_id = 4;
$stmt-&gt;bindParam(&apos;name&apos;, $name, PDO::PARAM_STR);
$stmt-&gt;bindParam(&apos;alias&apos;, $alias, PDO::PARAM_STR);
$stmt-&gt;bindParam(&apos;cate_id&apos;, $cate_id, PDO::PARAM_INT);

// 5. &#x6267;&#x884C;SQL&#x64CD;&#x4F5C;
if ($stmt-&gt;execute()) {
	if ($stmt-&gt;rowCount() &gt; 0) {
		echo &apos;&#x6210;&#x529F;&#x66F4;&#x65B0;&#x4E86;&apos; . $stmt-&gt;rowCount() . &apos;&#x6761;&#x8BB0;&#x5F55;&apos;;
	}
} else {
	die(&apos;&lt;pre&gt;&apos; . print_r($stmt-&gt;errorInfo(), true));
}

// 6. &#x9500;&#x6BC1;pdo, &#x5173;&#x95ED;&#x8FDE;&#x63A5;
$pdo = null;   // unset($pdo) &#x7B49;&#x4EF7;
</code></pre><pre data-role="codeBlock" data-info class="language-"><code># &#x5220;&#x9664;&#x8BB0;&#x5F55;
// 1. &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;
require __DIR__ . &apos;/connect.php&apos;;

// 2. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;
$sql = &apos;DELETE FROM  `category`  WHERE `cate_id`=:cate_id&apos;;

// 3. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x5BF9;&#x8C61;
$stmt = $pdo-&gt;prepare($sql);

// 4. &#x5C06;&#x53D8;&#x91CF;&#x7ED1;&#x5B9A;&#x5230;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;&#x7684;&#x547D;&#x540D;&#x5360;&#x4F4D;&#x7B26;&#x4E0A;
$cate_id = 4;
$stmt-&gt;bindParam(&apos;cate_id&apos;, $cate_id, PDO::PARAM_INT);

// 5. &#x6267;&#x884C;SQL&#x64CD;&#x4F5C;
if ($stmt-&gt;execute()) {
	if ($stmt-&gt;rowCount() &gt; 0) {
		echo &apos;&#x6210;&#x529F;&#x5220;&#x9664;&#x4E86;&apos; . $stmt-&gt;rowCount() . &apos;&#x6761;&#x8BB0;&#x5F55;&apos;;
	}
} else {
	die(&apos;&lt;pre&gt;&apos; . print_r($stmt-&gt;errorInfo(), true));
}

// 6. &#x9500;&#x6BC1;pdo, &#x5173;&#x95ED;&#x8FDE;&#x63A5;
$pdo = null;   // unset($pdo) &#x7B49;&#x4EF7;
</code></pre><pre data-role="codeBlock" data-info class="language-"><code># &#x67E5;&#x8BE2;1: fetch() + while()
// 1. &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;
require __DIR__ . &apos;/connect.php&apos;;

// 2. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;
$sql = &apos;SELECT * FROM  `movies`  WHERE `cate_id` = :cate_id&apos;;

// 3. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x5BF9;&#x8C61;
$stmt = $pdo-&gt;prepare($sql);

// 4. &#x5C06;&#x53D8;&#x91CF;&#x7ED1;&#x5B9A;&#x5230;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;&#x7684;&#x547D;&#x540D;&#x5360;&#x4F4D;&#x7B26;&#x4E0A;
$cate_id = 1;
$stmt-&gt;bindParam(&apos;cate_id&apos;, $cate_id, PDO::PARAM_INT);

// 5. &#x6267;&#x884C;SQL&#x64CD;&#x4F5C;
$stmt-&gt;execute();

// &#x904D;&#x5386;
while ($movie = $stmt-&gt;fetch(PDO::FETCH_ASSOC)) {
	echo &apos;&lt;pre&gt;&apos; . print_r($movie, true);
}

// 6. &#x9500;&#x6BC1;pdo, &#x5173;&#x95ED;&#x8FDE;&#x63A5;
$pdo = null;   // unset($pdo) &#x7B49;&#x4EF7;
</code></pre><pre data-role="codeBlock" data-info class="language-"><code># &#x67E5;&#x8BE2;2: fetchAll()
// 1. &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;
require __DIR__ . &apos;/connect.php&apos;;

// 2. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;
$sql = &apos;SELECT * FROM  `movies`  WHERE `cate_id` = :cate_id&apos;;

// 3. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x5BF9;&#x8C61;
$stmt = $pdo-&gt;prepare($sql);

// 4. &#x5C06;&#x53D8;&#x91CF;&#x7ED1;&#x5B9A;&#x5230;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;&#x7684;&#x547D;&#x540D;&#x5360;&#x4F4D;&#x7B26;&#x4E0A;
$cate_id = 3;
$stmt-&gt;bindParam(&apos;cate_id&apos;, $cate_id, PDO::PARAM_INT);

// 5. &#x6267;&#x884C;SQL&#x64CD;&#x4F5C;
$stmt-&gt;execute();

// &#x904D;&#x5386;, &#x8FD4;&#x56DE;&#x4E8C;&#x7EF4;&#x6570;&#x7EC4;
$movies = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);

foreach ($movies as $movie) {
	echo &apos;&lt;pre&gt;&apos; . print_r($movie, true);
}

// 6. &#x9500;&#x6BC1;pdo, &#x5173;&#x95ED;&#x8FDE;&#x63A5;
$pdo = null;   // unset($pdo) &#x7B49;&#x4EF7;
</code></pre><pre data-role="codeBlock" data-info class="language-"><code># &#x67E5;&#x8BE2;3: bindColumn()
// 1. &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;
require __DIR__ . &apos;/connect.php&apos;;

// 2. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;
$sql = &apos;SELECT * FROM  `movies`  WHERE `cate_id` = :cate_id&apos;;

// 3. &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x5BF9;&#x8C61;
$stmt = $pdo-&gt;prepare($sql);

// 4. &#x5C06;&#x53D8;&#x91CF;&#x7ED1;&#x5B9A;&#x5230;SQL&#x8BED;&#x53E5;&#x6A21;&#x677F;&#x7684;&#x547D;&#x540D;&#x5360;&#x4F4D;&#x7B26;&#x4E0A;
$cate_id = 3;
$stmt-&gt;bindParam(&apos;cate_id&apos;, $cate_id, PDO::PARAM_INT);

// 5. &#x6267;&#x884C;SQL&#x64CD;&#x4F5C;
$stmt-&gt;execute();

// &#x5C06;&#x7ED3;&#x679C;&#x96C6;&#x4E2D;&#x7684;&#x8BB0;&#x5F55;&#x4E2D;&#x7684;&#x5B57;&#x6BB5;, &#x7ED1;&#x5B9A;&#x5230;&#x6307;&#x5B9A;&#x7684;&#x53D8;&#x91CF;&#x4E0A;
$stmt-&gt;bindColumn(&apos;name&apos;, $name);
$stmt-&gt;bindColumn(&apos;detail&apos;, $detail);

while ($stmt-&gt;fetch(PDO::FETCH_ASSOC)) {
	$detail = mb_substr($detail,0, 20,&apos;utf-8&apos;);
	echo &apos;&#x7247;&#x540D;:  &apos; . $name . &apos;&lt;br&gt;&apos; . &apos;&#x7B80;&#x4ECB;:  &apos; . $detail . &apos;...&lt;hr&gt;&apos;;
}

// 6. &#x9500;&#x6BC1;pdo, &#x5173;&#x95ED;&#x8FDE;&#x63A5;
$pdo = null;   // unset($pdo) &#x7B49;&#x4EF7;
</code></pre><hr>
<h3 class="mume-header" id="6-pdo%E6%93%8D%E4%BD%9C%E6%95%B0%E6%8D%AE%E5%BA%93%E5%9F%BA%E6%9C%AC%E6%B5%81%E7%A8%8B">6. pdo&#x64CD;&#x4F5C;&#x6570;&#x636E;&#x5E93;&#x57FA;&#x672C;&#x6D41;&#x7A0B;</h3>

<ol>
<li>&#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;,&#x521B;&#x5EFA;pdo&#x5BF9;&#x8C61;</li>
</ol>
<ul>
<li><code>$pdo = new PDO($dsn, $username, $password);</code></li>
</ul>
<ol start="2">
<li>&#x6267;&#x884C;SQL&#x8BED;&#x53E5;&#x5B8C;&#x6210;&#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;</li>
</ol>
<ul>
<li>&#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;&#x5BF9;&#x8C61;: <code>$stmt = $pdo-&gt;prepare($sql)</code></li>
<li>&#x6267;&#x884C;SQL&#x67E5;&#x8BE2;: <code>$stmt-&gt;execute()</code></li>
<li>&#x5BF9;&#x6267;&#x884C;&#x7ED3;&#x679C;&#x8FDB;&#x884C;&#x89E3;&#x6790;&#x6216;&#x8FDB;&#x4E00;&#x6B65;&#x5904;&#x7406;</li>
</ul>
<ol start="3">
<li>[&#x53EF;&#x9009;]&#x9500;&#x6BC1;pdo&#x5BF9;&#x8C61;,&#x5173;&#x95ED;&#x8FDE;&#x63A5;: <code>$pdo = null</code></li>
</ol>
<p><img src="http://kanyun.8car.net/php/db8.png" alt></p>
<hr>
<h1 class="mume-header" id="-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%AE%A1%E7%90%86%E7%BD%91%E7%AB%99%E5%86%85%E5%AE%B9">:-: &#x6570;&#x636E;&#x5E93;&#x7BA1;&#x7406;&#x7F51;&#x7AD9;&#x5185;&#x5BB9;</h1>

<h3 class="mume-header" id="1-connectphp%E5%85%AC%E5%85%B1%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6">1&#x3001;<code>connect.php</code>&#x516C;&#x5171;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</h3>

<pre data-role="codeBlock" data-info class="language-"><code>// &#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;&#x53C2;&#x6570;
$db =  [
    &apos;type&apos; =&gt; &apos;mysql&apos;,
    &apos;host&apos; =&gt; &apos;localhost&apos;,
    &apos;dbname&apos; =&gt; &apos;php&apos;,
    &apos;username&apos; =&gt; &apos;root&apos;,
    &apos;password&apos; =&gt; &apos;root&apos;,
];

// &#x914D;&#x7F6E;&#x6570;&#x636E;&#x6E90;DSN&#x4FE1;&#x606F;
$dsn = &quot;{$db[&apos;type&apos;]}:host={$db[&apos;host&apos;]};dbname={$db[&apos;dbname&apos;]}&quot;;

// &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;
try {
	$pdo = new PDO($dsn, $db[&apos;username&apos;], $db[&apos;password&apos;]);
} catch (PDOException $e) {
	die(&apos;Connection Failed: &apos; . $e-&gt;getMessage());
}
</code></pre><hr>
<h3 class="mume-header" id="2-%E5%A4%B4%E5%B0%BE%E5%85%AC%E5%85%B1%E6%96%87%E4%BB%B6-headerphp-%E5%92%8C-footerphp">2&#x3001;&#x5934;&#x5C3E;&#x516C;&#x5171;&#x6587;&#x4EF6; <code>header.php</code> &#x548C; <code>footer.php</code></h3>

<pre data-role="codeBlock" data-info class="language-"><code>&lt;?php
	// &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;:$pdo
	require &apos;connect.php&apos;;

	// &#x83B7;&#x53D6;&#x7F51;&#x7AD9;&#x914D;&#x7F6E;&#x4FE1;&#x606F;(SEO)
	$sql = &apos;SELECT * FROM `system` LIMIT 1&apos;;
	$stmt = $pdo-&gt;prepare($sql);
	$stmt-&gt;execute();
	$system = $stmt-&gt;fetch(PDO::FETCH_ASSOC);

	// &#x83B7;&#x53D6;&#x680F;&#x76EE;&#x4FE1;&#x606F;
	$sql = &apos;SELECT `cate_id`,`name`,`alias` FROM `category`&apos;;
	$stmt = $pdo-&gt;prepare($sql);
	$stmt-&gt;execute();
	$cates = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
	$cate_count = count($cates);    // &#x680F;&#x76EE;&#x6570;&#x91CF;

	// &#x83B7;&#x53D6;&#x5F71;&#x89C6;&#x4FE1;&#x606F;
	$sql = &apos;SELECT `mov_id`,`name`,`image`, `detail`, `cate_id` FROM `movies`&apos;;
	$stmt = $pdo-&gt;prepare($sql);
	$stmt-&gt;execute();
	$movies = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
?&gt;

&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;meta charset=&quot;UTF-8&quot;&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;css/style.css&quot;&gt;
	&lt;meta name=&quot;description&quot; content=&quot;&lt;?php echo $system[&apos;desc&apos;] ?&gt;&quot;&gt;
	&lt;meta name=&quot;keywords&quot; content=&quot;&lt;?php echo $system[&apos;key&apos;] ?&gt;&quot;&gt;
	&lt;title&gt;&lt;?php echo $system[&apos;title&apos;] ?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;!--&#x5934;&#x90E8;&#x5BFC;&#x822A;--&gt;
&lt;div class=&quot;header&quot;&gt;
	&lt;ul class=&quot;nav&quot;&gt;
		&lt;li&gt;&lt;a href=&quot;index.php&quot;&gt;&#x9996;&#x9875;&lt;/a&gt;&lt;/li&gt;
		&lt;?php foreach ($cates as $cate) : ?&gt;
			&lt;li&gt;&lt;a href=&quot;list.php?cate_id=&lt;?php echo $cate[&apos;cate_id&apos;]; ?&gt;&quot;&gt;&lt;?php echo $cate[&apos;alias&apos;] ?&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;?php endforeach; ?&gt;
	&lt;/ul&gt;
&lt;/div&gt;
</code></pre><pre data-role="codeBlock" data-info class="language-"><code>&lt;!--&#x5E95;&#x90E8;&#x7248;&#x6743;--&gt;
&lt;div class=&quot;footer&quot;&gt;
	&lt;p class=&quot;copyright&quot;&gt;&lt;?php echo $system[&apos;copy&apos;]; ?&gt;&amp;copy; &#x7248;&#x6743;&#x6240;&#x6709;&lt;/p&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre><hr>
<h3 class="mume-header" id="3-%E6%A0%B7%E5%BC%8F%E5%92%8C%E5%9B%BE%E7%89%87">3&#x3001;&#x6837;&#x5F0F;&#x548C;&#x56FE;&#x7247;</h3>

<pre data-role="codeBlock" data-info="css" class="language-css"><span class="token selector"># style<span class="token class">.css</span>
<span class="token class">.header</span></span> <span class="token punctuation">{</span>
	<span class="token property">background-color</span><span class="token punctuation">:</span> brown<span class="token punctuation">;</span>
	<span class="token property">height</span><span class="token punctuation">:</span> <span class="token number">30</span><span class="token unit">px</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector"><span class="token class">.nav</span> li</span> <span class="token punctuation">{</span>
	<span class="token property">list-style</span><span class="token punctuation">:</span>none<span class="token punctuation">;</span>
	<span class="token property">min-width</span><span class="token punctuation">:</span><span class="token number">80</span><span class="token unit">px</span><span class="token punctuation">;</span>
	<span class="token property">line-height</span><span class="token punctuation">:</span> <span class="token number">30</span><span class="token unit">px</span><span class="token punctuation">;</span>
	<span class="token property">float</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector"><span class="token class">.nav</span> li a</span> <span class="token punctuation">{</span>
	<span class="token property">text-decoration</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span>
	<span class="token property">color</span><span class="token punctuation">:</span> white<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector"><span class="token class">.nav</span></span> <span class="token punctuation">{</span>
	<span class="token property">overflow</span><span class="token punctuation">:</span> hidden<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector"><span class="token class">.footer</span></span> <span class="token punctuation">{</span>
	<span class="token property">height</span><span class="token punctuation">:</span> <span class="token number">30</span><span class="token unit">px</span><span class="token punctuation">;</span>
	<span class="token property">background-color</span><span class="token punctuation">:</span> <span class="token hexcode">#636363</span><span class="token punctuation">;</span>
	<span class="token property">color</span><span class="token punctuation">:</span> white<span class="token punctuation">;</span>
	<span class="token property">text-align</span><span class="token punctuation">:</span> center<span class="token punctuation">;</span>
	<span class="token property">line-height</span><span class="token punctuation">:</span> <span class="token number">30</span><span class="token unit">px</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><img src="http://kanyun.8car.net/php/1.jpg" width="100" height="100" alt="&#x56FE;&#x7247;&#x540D;&#x79F0;" align="center">
<img src="http://kanyun.8car.net/php/2.jpg" width="100" height="100" alt="&#x56FE;&#x7247;&#x540D;&#x79F0;" align="center">
<img src="http://kanyun.8car.net/php/3.jpg" width="100" height="100" alt="&#x56FE;&#x7247;&#x540D;&#x79F0;" align="center">
<img src="http://kanyun.8car.net/php/4.jpg" width="100" height="100" alt="&#x56FE;&#x7247;&#x540D;&#x79F0;" align="center">
<img src="http://kanyun.8car.net/php/5.jpg" width="100" height="100" alt="&#x56FE;&#x7247;&#x540D;&#x79F0;" align="center">
<img src="http://kanyun.8car.net/php/6.jpg" width="100" height="100" alt="&#x56FE;&#x7247;&#x540D;&#x79F0;" align="center">
<img src="http://kanyun.8car.net/php/7.jpg" width="100" height="100" alt="&#x56FE;&#x7247;&#x540D;&#x79F0;" align="center">
<img src="http://kanyun.8car.net/php/8.jpg" width="100" height="100" alt="&#x56FE;&#x7247;&#x540D;&#x79F0;" align="center">
<img src="http://kanyun.8car.net/php/9.jpg" width="100" height="100" alt="&#x56FE;&#x7247;&#x540D;&#x79F0;" align="center">
<hr>
<h3 class="mume-header" id="4-%E9%A6%96%E9%A1%B5">4&#x3001;&#x9996;&#x9875;</h3>

<pre data-role="codeBlock" data-info class="language-"><code>include __DIR__ . &quot;/header.php&quot;;

foreach ($cates as $cate) {
	echo &quot;&lt;h2&gt;{$cate[&apos;alias&apos;]}&lt;/h2&gt;&quot;;
	echo &apos;&lt;ol&gt;&apos;;
	foreach ($movies as $movie) {
		if ($cate[&apos;cate_id&apos;] === $movie[&apos;cate_id&apos;]) {
			echo &quot;&lt;li&gt;&lt;a href=&apos;detail.php?mov_id=&quot; .$movie[&apos;mov_id&apos;]. &quot;&apos;&gt;{$movie[&apos;name&apos;]}&lt;/a&gt;&lt;/li&gt;&quot;;
		}
	}
	echo &apos;&lt;/ol&gt;&apos;;
}

include __DIR__ . &apos;/footer.php&apos;;
</code></pre><hr>
<h3 class="mume-header" id="5-%E5%88%97%E8%A1%A8">5&#x3001;&#x5217;&#x8868;</h3>

<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">include</span> <span class="token constant">__DIR__</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;/header.php&apos;</span><span class="token punctuation">;</span>

<span class="token comment">// &#x83B7;&#x53D6;&#x680F;&#x76EE;ID</span>
<span class="token comment">// &#x6CE8;: &#x6570;&#x636E;&#x8868;&#x8BFB;&#x53D6;&#x7684;&#x503C;,&#x90FD;&#x662F;&#x4EE5;&#x5B57;&#x7B26;&#x7C7B;&#x578B;,&#x8FD9;&#x91CC;&#x4E0D;&#x5FC5;&#x518D;&#x8F6C;&#x6362;</span>
<span class="token variable">$cate_id</span> <span class="token operator">=</span> <span class="token global">$_GET</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;cate_id&apos;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token keyword">foreach</span> <span class="token punctuation">(</span><span class="token variable">$cates</span> <span class="token keyword">as</span> <span class="token variable">$cate</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
	<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$cate</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;cate_id&apos;</span><span class="token punctuation">]</span> <span class="token operator">===</span> <span class="token variable">$cate_id</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token double-quoted-string string">&quot;&lt;h2&gt;<span class="token interpolation"><span class="token punctuation">{</span><span class="token variable">$cate</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;alias&apos;</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span>&lt;/h2&gt;&quot;</span><span class="token punctuation">;</span>
		<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;ol&gt;&apos;</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x904D;&#x5386;&#x8BE5;&#x680F;&#x76EE;ID&#x5BF9;&#x5E94;&#x7684;&#x5F71;&#x89C6;&#x4FE1;&#x606F;</span>
		<span class="token keyword">foreach</span> <span class="token punctuation">(</span><span class="token variable">$movies</span> <span class="token keyword">as</span> <span class="token variable">$movie</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
			<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$cate</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;cate_id&apos;</span><span class="token punctuation">]</span> <span class="token operator">===</span> <span class="token variable">$movie</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;cate_id&apos;</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
				<span class="token keyword">echo</span> <span class="token double-quoted-string string">&quot;&lt;li&gt;&lt;a href=&apos;detail.php?mov_id=&quot;</span> <span class="token punctuation">.</span><span class="token variable">$movie</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;mov_id&apos;</span><span class="token punctuation">]</span><span class="token punctuation">.</span> <span class="token double-quoted-string string">&quot;&apos;&gt;<span class="token interpolation"><span class="token punctuation">{</span><span class="token variable">$movie</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;name&apos;</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span>&lt;/a&gt;&lt;/li&gt;&quot;</span><span class="token punctuation">;</span>
			<span class="token punctuation">}</span>
		<span class="token punctuation">}</span>
		<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;/ol&gt;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">include</span> <span class="token constant">__DIR__</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;/footer.php&apos;</span><span class="token punctuation">;</span>
</pre><hr>
<h3 class="mume-header" id="6-%E8%AF%A6%E6%83%85">6&#x3001;&#x8BE6;&#x60C5;</h3>

<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">include</span> <span class="token constant">__DIR__</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;/header.php&apos;</span><span class="token punctuation">;</span>

<span class="token variable">$mov_id</span> <span class="token operator">=</span> <span class="token global">$_GET</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;mov_id&apos;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">foreach</span> <span class="token punctuation">(</span><span class="token variable">$movies</span> <span class="token keyword">as</span> <span class="token variable">$movie</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
	<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$movie</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;mov_id&apos;</span><span class="token punctuation">]</span> <span class="token operator">===</span> <span class="token variable">$mov_id</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
		<span class="token keyword">echo</span>  <span class="token double-quoted-string string">&quot;&lt;h3&gt;<span class="token interpolation"><span class="token punctuation">{</span><span class="token variable">$movie</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;name&apos;</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span>&lt;/h3&gt;&quot;</span><span class="token punctuation">;</span>
		<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;img src=&quot;/images/&apos;</span><span class="token punctuation">.</span><span class="token variable">$movie</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;image&apos;</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;&quot; alt=&quot;&quot; width=&quot;300&quot;&gt;&apos;</span><span class="token punctuation">;</span>
		<span class="token keyword">echo</span> <span class="token double-quoted-string string">&quot;&lt;p style=&apos;text-indent: 2em&apos;&gt;<span class="token interpolation"><span class="token punctuation">{</span><span class="token variable">$movie</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;detail&apos;</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span>&lt;/p&gt;&quot;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token keyword">include</span> <span class="token constant">__DIR__</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;/inc/footer.php&apos;</span><span class="token punctuation">;</span>
</pre>
      </div>
      
      
    
    
    
    
    
    
    
    
  
    </body></html>